@extends('layouts.userctl')
@section('content')
<style>
	.layui-card-header {
		margin-top: 15px;
	}

	/* .layui-table-cell {
		display: flex;
		align-items: center;
	}
 */
	.userstatus {
		margin-left: 6px;
		color: #888;
		font-size: 14px;
	}

	.layui-table-tips-c::before {
		position: absolute !important;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0px !important;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>
{{csrf_field()}}
<div class="layuimini-container">
	<div class="layuimini-main">
		<div style="margin: 10px 10px 10px 10px" id="btn">
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item">
					
					<div class="layui-inline" style="float: left;">
						<a class="layui-btn layui-btn-normal" href="/admin/staff/index2"
							style="color: #fff;">返  回</a>
					</div>
				</div>
			</form>
		</div>
		<!--注意此处table标签里的id-->
		<table class="layui-table layui-hide" id="dataTable" lay-filter="dataTable"></table>
	</div>
</div>


<script>
	layui.use(['layer', 'table', 'form'], function() {
		var layer = layui.layer
		var form = layui.form
		var table = layui.table
		//用户表格初始化
		var dataTable = table.render({
			elem: '#dataTable',
			height: 'full',
			limit: 12,
			url: '{{ route("admin.user.reportlist") }}',
			where: { userid:{{$userid}} },
			page: true,
			cols: [
				[ //表头
					{ title: '序 号',templet: function(d) {
							return d.LAY_INDEX
						},align:'center'
					},
					{ field: 'day', title: '填报日期' },
					{
						title: '填报人',
						templet: function(d) {
							return d.userinfo.name
						}
					},
					{ field: 'summary', title: '内容'},
				]
			],
			done: function(response) { //定位当前table视图
				//动态监听表头高度变化，冻结行跟着改变高度
				$('.layui-table-header  tr').resize(function() {
					$('.layui-table-header  tr').each(function(index, val) {
						$($('.layui-table-fixed .layui-table-header table tr')[index])
							.height($(val).height())
					})
				})
				//初始化高度，使得冻结行表头高度一致
				$('.layui-table-header  tr').each(function(index, val) {
					$($('.layui-table-fixed .layui-table-header table tr')[index]).height($(
						val).height())
				})
				//表体部分
				//动态监听表体高度变化，冻结行跟着改变高度
				$('.layui-table-body  tr').resize(function() {
					$('.layui-table-body  tr').each(function(index, val) {
						$($('.layui-table-fixed .layui-table-body table tr')[index])
							.height($(val).height())
					})
				})
				//初始化高度，使得冻结行表体高度一致
				$('.layui-table-body  tr').each(function(index, val) {
					$($('.layui-table-fixed .layui-table-body table tr')[index]).height($(val)
						.height())
				})
				var tableView = this.elem.next()

			}
		})
		$('#searchbtn').click(function() {
			dataTable.reload({
				where: { keyword: $('#keywordinput').val() },
				page: { curr: 1 }
			})
		})
		//监听工具条
		table.on('tool(dataTable)', function(obj) { //注：tool是工具条事件名，dataTable是table原始容器的属性 lay-filter="对应的值"
			var data = obj.data //获得当前行数据
				,
				layEvent = obj.event //获得 lay-event 对应的值
			if (layEvent === 'del') {
				layer.confirm('确认删除该部门吗', { btn: ['确认', '取消'] }, function(index, layero) {
					var id = data.id
					$.ajax({
						type: 'POST',
						headers: { 'X-CSRF-TOKEN': $('input[name="_token"]').val() },
						url: '/admin/user/deldep',
						data: { id },
						success: function(res) {
							if (res.code == '1') {
								layer.msg(res.msg, { icon: 6 })
								setTimeout(function(){
									location.href = '/admin/user/deplist'
								},1500)
							}else{
								layer.msg(res.msg, { icon: 5 })
							}
						}
					})
				}, function(index) {

				})
			} else if (layEvent === 'edit') {
				location.href = '/admin/user/depedit?id=' + data.id
			}
		})
	})
</script>
@endsection
